﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Unity.Game.ElisAdvance.ElisScript
{
    public class ElisState_HoldWall
    {

        public static void onFixedProc(ElisActiveObject activeObject, float horiztantlKey)
        {
            float dir = activeObject.getVar("GLOBAL_Hold_Direction").get_vector(0);
            if (dir == 1.0f)
            {

                if (KeyPressEvent.isKeyPressDownJump())
                {
                    activeObject.clearStateVector();
                    activeObject.pushStateVector(0);
                    activeObject.setState(State.STATE_JUMP);
                    activeObject.setXVelocity(-5.0f);
                }

                if (!KeyPressEvent.isKeyPressRight())
                {
                    activeObject.clearStateVector();
                    activeObject.pushStateVector(1);
                    activeObject.setState(State.STATE_JUMP);
                }
            }
        }
        public static void onSetState(ElisActiveObject activeObject)
        {
            float subState = activeObject.getStateVector(0);
            float direction = activeObject.getStateVector(1);

            if (subState == 0)
            {
                activeObject.getVar("GLOBAL_Hold_Direction").clear_vector();
                activeObject.getVar("GLOBAL_Hold_Direction").push_vector(direction);
                activeObject.setXVelocity(0.0f);
                activeObject.setYVelocity(0.0f);
                activeObject.getAni().SetTrigger("Jump");
                activeObject.getGravityEvent().setEnable(false);
            }
        }
    }
}
